package models

import (
	"gorm.io/gorm"
	"time"
	"user_srv/basic/config"
)

// 用户钱包表
type UserWallet struct {
	Id                       int64          `gorm:"column:id;type:bigint;primaryKey;not null;" json:"id"`
	UserId                   int32          `gorm:"column:user_id;type:int;default:NULL;" json:"user_id"`
	UserAvailableBalance     string         `gorm:"column:user_available_balance;type:varchar(255);comment:可用余额;default:NULL;" json:"user_available_balance"`              // 可用余额
	UserFrozenBalance        string         `gorm:"column:user_frozen_balance;type:varchar(255);comment:冻结中余额;default:NULL;" json:"user_frozen_balance"`                   // 冻结中余额
	UserInvoiceableAmount    string         `gorm:"column:user_invoiceable_amount;type:varchar(255);comment:可开发票金额;default:NULL;" json:"user_invoiceable_amount"`          // 可开发票金额
	UninvoicedAmountForTrips string         `gorm:"column:uninvoiced_amount_for_trips;type:varchar(255);comment:行程未开票金额;default:NULL;" json:"uninvoiced_amount_for_trips"` // 行程未开票金额
	CreatedAt                time.Time      `gorm:"column:created_at;type:datetime(3);default:CURRENT_TIMESTAMP(3);" json:"created_at"`
	UpdatedAt                time.Time      `gorm:"column:updated_at;type:datetime(3);not null;default:CURRENT_TIMESTAMP(3);" json:"updated_at"`
	DeletedAt                gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3);default:NULL;" json:"deleted_at"`
}

func (u *UserWallet) TableName() string {
	return "user_wallet"
}

// 创建
func (u *UserWallet) Create() error {
	return config.DB.Create(u).Error
}
